<template>
  <div>
    <p>{{ form.username }}
      {{ form.password }}</p>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="账号">
        <el-input v-model="form.username"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="form.password"></el-input>
      </el-form-item>
      <el-button type="primary" @click="onSubmit">登录</el-button>
    </el-form>
  </div>
</template>

<script>
import axios from 'axios'
import Qs from 'qs'

export default {
  name: 'test',
  data () {
    return {
      form: {
        username: '',
        password: ''
      }
    }
  },
  methods: {
    onSubmit () {
      let formDate = {
        username: this.form.username,
        password: this.form.password
      }
      axios.post('/login', Qs.stringify(formDate), {
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded'
        }
      }).then(function (response) {
        this.$message({
          message: '恭喜你，这是一条成功消息',
          type: 'success'
        })
      }.bind(this))
    }
  }
}
</script>
<style>
</style>
